<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!--类别数据 --左侧树   -->
      <el-col :span="4" :xs="24">
        <div class="head-container">
          <el-input
              v-model="categoryName"
              placeholder="请输入预测范围名称"
              clearable
              prefix-icon="Search"
              style="margin-bottom: 20px"
          />
        </div>
        <div class="tree-container">
          <el-tree
              :data="categoryOptions"
              :props="{ label: 'label', children: 'children' }"
              :expand-on-click-node="false"
              :filter-node-method="filterNode"
              ref="categoryTreeRef"
              node-key="id"
              highlight-current
              default-expand-all
              @node-click="handleNodeClick"
          >

          </el-tree>
        </div>
      </el-col>

      <el-col :span="20" :xs="24">
        <!--编制工作台查询区域-->
        <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="108px">
          <el-form-item label="模型编码" prop="code">
            <el-input
                v-model="queryParams.code"
                placeholder="请输入分析模型"
                clearable
                @keyup.enter="handleQuery"
            />
          </el-form-item>
          <el-form-item label="分析模型名称" prop="code">
            <el-input
                v-model="queryParams.name"
                placeholder="请输入分析模型名称"
                clearable
                @keyup.enter="handleQuery"
            />
          </el-form-item>
          <el-form-item label="模型类型" prop="type">
            <el-select v-model="queryParams.type" style="width: 200px" clearable @keyup.enter="handleQuery">
              <el-option label="折线图" value="0"/>
              <el-option label="柱状图" value="1"/>
              <el-option label="饼图" value="2"/>
              <el-option label="散点图" value="3"/>
              <el-option label="k线图" value="4"/>
              <el-option label="k线图" value="5"/>
              <el-option label="表格" value="6"/>
            </el-select>
          </el-form-item>
          <el-form-item label="启用状态" prop="enable">
            <el-select v-model="queryParams.enable" style="width: 200px" clearable @keyup.enter="handleQuery">
              <el-option label="停用" value="0"/>
              <el-option label="启用" value="1"/>
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
        <!--操作按钮-->
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
                type="primary"
                plain
                icon="Plus"
                @click="handleAdd"
                v-hasPermi="['keyfigure:template:add']"
            >新增
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
                type="danger"
                plain
                icon="Delete"
                @click="handleDelete"
            >删除
            </el-button>
          </el-col>
          <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
        <!--分析模型列表-->
        <el-table class="table-container" v-loading="loading"
                  stripe
                  border
                  :data="modelList"
                  :show-overflow-tooltip='true'
                  :header-cell-style="{'border-right':'1px solid #EEEEEE'}"
                  :cell-style="{'border-right':'1px solid #EEEEEE'}"
                  :row-class-name="iconHadler"
                  @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center"/>
          <el-table-column label="序号" align="center" prop="index" width="60"/>
          <el-table-column label="计划范围" align="center" prop="planAreaId" width="140" :show-overflow-tooltip="true">
            <template #default="scope">
              {{ getPlanAreaName(scope.row.planAreaId) }}
            </template>
          </el-table-column>
          <el-table-column label="模型编码" align="center" prop="code" width="80"/>
          <el-table-column label="分析模型名称" align="center" prop="name" width="180" :show-overflow-tooltip="true"/>
          <el-table-column label="指标" align="center" prop="keyfingureIds" :show-overflow-tooltip="true" width="440">
            <template #default="scope">
              {{ getKeyfigureLabel(scope.row.keyfingureIds) }}
            </template>
          </el-table-column>
          <el-table-column label="模型类型" align="center" prop="type" :show-overflow-tooltip="true" width="100">
            <template #default="scope">
              {{ getTypeLable(scope.row.type) }}
            </template>
          </el-table-column>
          <el-table-column label="启用状态" align="center" key="enable" prop="enable" :show-overflow-tooltip="true"
                           width="80">
            <template #default="scope">
              <el-switch
                  v-model="scope.row.enable"
                  active-value="1"
                  inactive-value="0"
                  @change="handleStatusChange(scope.row)"
              ></el-switch>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template #default="scope">
              <el-button link type="primary" icon="Edit" @click="handleView(scope.row)"
                         v-hasPermi="['template:template:edit']">查看模型
              </el-button>
              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
                         v-hasPermi="['template:template:edit']">修改
              </el-button>
              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
                         v-hasPermi="['template:template:remove']">删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>

      </el-col>

    </el-row>


    <el-dialog :title="title" v-model="openView" width="950px" append-to-body>
      <div style="width: 900px;height: 300px;margin-top: 20px;" v-if="echartShow">
        <!-- 第一个v-chart区域 -->
        <v-chart
            class="chart"
            ref="myChart"
            :option="charData"
            width="100%"
            height="100%"
        />
      </div>
      <div style="width: 900px;height: 300px;" v-if="!echartShow">
        <el-table :data="state.tableData.data"
                  v-loading="state.tableData.loading"
                  stripe
                  border>
          <el-table-column v-for="column in state.tableData.header" align="center" :min-width="column.width"
                           :key="column.column" :label="column.columnName" :prop="column.column">
            <el-table-column v-if="column.children?.length > 0" v-for="(item,index) in column.children" align="center"
                             :min-width="item.width" :key="index" :label="item.columnName"
                             :prop="item.column"></el-table-column>
          </el-table-column>
        </el-table>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="cancelView">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 添加或修改参数模板对话框 -->
    <el-dialog :title="title" v-model="open" width="750px" append-to-body>
      <el-form ref="templateRef" :model="form" :inline="true" :rules="rules" label-width="100px">
        <el-form-item label="id" prop="id" v-if="false">
          <el-input v-model="form.id" placeholder="请输入模型id"/>
        </el-form-item>
        <el-form-item label="计划范围" label-width="100px" prop="planAreaId">
          <el-tree-select
              style="width:230px;"
              v-model="form.planAreaId"
              :data="categoryOptions"
              :props="{ label: 'label', children: 'children' }"
              value-key="id"
              placeholder="选择计划范围"
              check-strictly
          />
        </el-form-item>
        <el-form-item label="模型编码" label-width="100px" prop="code">
          <el-input v-model="form.code" placeholder="请输入分析模型编码"/>
        </el-form-item>
        <el-form-item label="分析模型名称" label-width="120px" prop="name">
          <el-input v-model="form.name" :min="1" placeholder="请输入分析模型名称"/>
        </el-form-item>
        <el-form-item label="指标" prop="keyfingureIds" :show-overflow-tooltip="true">
          <el-select
              v-model="form.keyfingureIds"
              multiple
              placeholder="请选择指标"
              style="width:630px;"
          >
            <el-option
                v-for="item in keyfingureOptions"
                :key="item.id"
                :label="item.name"
                :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="模型类型" prop="type" :show-overflow-tooltip="true">
          <el-select v-model="form.type" style="width: 200px">
            <el-option label="折线图" value="0"/>
            <el-option label="柱状图" value="1"/>
            <el-option label="饼图" value="2"/>
            <el-option label="散点图" value="3"/>
            <el-option label="k线图" value="4"/>
            <el-option label="k线图" value="5"/>
            <el-option label="表格" value="6"/>
          </el-select>
        </el-form-item>
        <el-form-item label="是否启用" label-width="100px" prop="enable">
          <el-select v-model="form.enable" style="width: 200px">
            <el-option label="停用" value="0"/>
            <el-option label="启用" value="1"/>
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="analysisModel">

import {ref, onMounted} from 'vue';
import RecursiveTableHeader from "@/components/RecursiveTableHeader";

const {proxy} = getCurrentInstance();
const title = ref("");
const selectTree = ref("");
const categoryName = ref("");

const open = ref(false);
const openView = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const selectPeriodType = ref({});
const categoryOptions = ref([
  {
    "id": 1,
    "label": "经济预测",
    "children": [
      {
        "id": 2,
        "label": "10年期经济预测"
      }
    ]
  },
  {
    "id": 3,
    "label": "发电量预测",
    "children": [
      {
        "id": 4,
        "label": "10年期发电量预测"
      }
    ]
  },
  {
    "id": 5,
    "label": "综合预测",
    "children": [
      {
        "id": 6,
        "label": "10年期综合预测"
      }
    ]
  }
]);
const keyfingureOptions = ref([
  {
    "id": 1,
    "code": "KF0001",
    "name": "核电装机容量",
    "isDefault": '0',
    "dataType": '0',
    "togetherType": '1',
    "enable": '1'
  },
  {
    "id": 2,
    "code": "KF0002",
    "name": "核能发电量",
    "dataType": '0',
    "togetherType": '1',
    "isDefault": '0',
    "enable": '1'
  },
  {
    "id": 3,
    "code": "KF0003",
    "name": "核能供热量",
    "dataType": '0',
    "togetherType": '1',
    "isDefault": '0',
    "enable": '1'
  },
  {
    "id": 4,
    "code": "KF0004",
    "name": "核能供汽量（万吨标煤）",
    "dataType": '0',
    "togetherType": '1',
    "isDefault": '0',
    "enable": '1'
  },
  {
    "id": 5,
    "code": "KF0005",
    "name": "核能制氢量（万吨）",
    "dataType": '0',
    "togetherType": '1',
    "isDefault": '0',
    "enable": '1'
  }
]);
const modelList = ref([{
  "id": 21,
  "planArea": "10年期经济预测",
  "planAreaId": 2,
  "code": "MK0001",
  "name": "核能供热量分析模型",
  "keyfingureIds": [
    1,
    3
  ],
  "enable": '1',
  "type": '0'
},
  {
    "id": 22,
    "planAreaId": 2,
    "planArea": "10年期经济预测",
    "code": "MK0022",
    "name": "核能供热量占比分析模型",
    "keyfingureIds": [
      1,
      3
    ],
    "enable": '1',
    "type": '2'
  }, {
    "id": 61,
    "planArea": "10年期综合预测",
    "planAreaId": 6,
    "code": "MK0003",
    "name": "装机容量分析模型",
    "keyfingureIds": [
      1,
      2
    ],
    "enable": '1',
    "type": '5'
  }, {
    "id": 41,
    "planArea": "10年期发电量预测",
    "planAreaId": 4,
    "code": "MK0002",
    "name": "发电量分析模型",
    "keyfingureIds": [
      1, 2
    ],
    "enable": '1',
    "type": '1'
  }]);

const oldmodelList = ref([{
  "id": 21,
  "planArea": "10年期经济预测",
  "planAreaId": 2,
  "code": "MK0001",
  "name": "核能供热量分析模型",
  "keyfingureIds": [
    3,
    4
  ],
  "enable": '1',
  "type": '0'
},
  {
    "id": 22,
    "planAreaId": 2,
    "planArea": "10年期经济预测",
    "code": "MK0022",
    "name": "核能供热量占比分析模型",
    "keyfingureIds": [
      3,
      4
    ],
    "enable": '1',
    "type": '2'
  }, {
    "id": 61,
    "planArea": "10年期综合预测",
    "planAreaId": 6,
    "code": "MK0003",
    "name": "装机容量分析模型",
    "keyfingureIds": [
      1,
      2
    ],
    "enable": '1',
    "type": '5'
  }, {
    "id": 41,
    "planArea": "10年期发电量预测",
    "planAreaId": 4,
    "code": "MK0002",
    "name": "发电量分析模型",
    "keyfingureIds": [
      1,2
    ],
    "enable": '1',
    "type": '1'
  }]);

const echartShow = ref(false);


const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    code: "",
    name: "",
    isDefault: null,
    enable: null,
    dyParams: {}
  },
  rules: {
    code: [{required: true, message: "维度code不能为空", trigger: "blur"}],
    name: [{required: true, message: "维度名称不能为空", trigger: "blur"}],
  }
});

const {queryParams, form, rules} = toRefs(data);

const charData = ref({});

const chartOptions = ref({
  title: {
    text: '发电量预测',
    left: 'center'
  },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  legend: {
    data: ['中长期仅新建四代堆-核能发电量（万亿千瓦时）', '中长期新建三代和四代堆-核能发电量（万亿千瓦时）'],
    right: 'right'
  },
  xAxis: {
    type: 'category',
    data: ['2030', '2040', '2050', '2060']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      name: '中长期仅新建四代堆-核能发电量（万亿千瓦时）',
      type: 'bar',
      data: [0.89, 1.96, 3.16, 3.44]
    },
    {
      name: '中长期新建三代和四代堆-核能发电量（万亿千瓦时）',
      type: 'bar',
      data: [0.89, 1.99, 3.24, 3.53]
    }
  ]
});

const pieOptions = ref({
  title: {
    text: '核能供汽量占比',
    left: 'center'
  },
  tooltip: {
    trigger: 'item'
  },
  series: [
    {
      name: '核能供汽量占比',
      type: 'pie',
      radius: '50%',
      data: [
        {value: 0.88, name: '2030年-中长期仅新建四代堆-供汽量占比'},
        {value: 5.01, name: '2040年-中长期仅新建四代堆-供汽量占比'},
        {value: 10.05, name: '2050年-中长期仅新建四代堆-供汽量占比'},
        {value: 13.56, name: '2060年-中长期仅新建四代堆-供汽量占比'},
        {value: 0.88, name: '2030年-中长期新建三代和四代堆-供汽量占比'},
        {value: 6.06, name: '2040年-中长期新建三代和四代堆-供汽量占比'},
        {value: 12.26, name: '2050年-中长期新建三代和四代堆-供汽量占比'},
        {value: 16.16, name: '2060年-中长期新建三代和四代堆-供汽量占比'}
      ],
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }
  ]
});


const chartLineOptions2 = ref({
  title: {
    text: '核能供汽量',
    left: 'center'
  },
  tooltip: {
    trigger: 'axis'
  },
  legend: {
    data: ['中长期仅新建四代堆-核能供汽量（万吨标煤）', '中长期新建三代和四代堆-核能供汽量（万吨标煤）'],
    right: 'right'
  },
  xAxis: {
    type: 'category',
    boundaryGap: false,
    data: ['2030', '2040', '2050', '2060']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      name: '中长期仅新建四代堆-核能供汽量（万吨标煤）',
      type: 'line',
      stack: '中长期仅新建四代堆-核能供汽量（万吨标煤）',
      data: [370, 1507, 2041, 2253]
    },
    {
      name: '中长期新建三代和四代堆-核能供汽量（万吨标煤）',
      type: 'line',
      stack: '中长期新建三代和四代堆-核能供汽量（万吨标煤）',
      data: [370, 1825, 2489, 2685]
    }
  ]
});

const myChart = ref(null);

/**
 * 定义表头属性映射关系
 */
const property = {
  prop: "column",
  label: "columnName",
  width: "width",
  children: "children",
};

const state = reactive({
  tableData: {
    loading: false,
    header: [
      {
        column: "dim1",
        columnName: "堆型",
        width: "100px",
        children: [],
      },
      {
        column: "dim3",
        columnName: "机组寿命",
        width: "100px",
        children: [],
      },
      {
        column: "dim4",
        columnName: "装机成本",
        width: "100px",
        children: [],
      },
      {
        column: "2030",
        columnName: "2030年",
        width: "560px",
        children: [
          {
            column: "kf12030",
            columnName: "核电装机容量(亿千瓦)",
            width: "280px",
            children: [],
          }
        ],
      }, {
        column: "2040",
        columnName: "2040年",
        width: "560px",
        children: [
          {
            column: "kf12040",
            columnName: "核电装机容量(亿千瓦)",
            width: "280px",
            children: [],
          }
        ],
      }, {
        column: "2050",
        columnName: "2050年",
        width: "560px",
        children: [
          {
            column: "kf12050",
            columnName: "核电装机容量(亿千瓦)",
            width: "280px",
            children: [],
          }
        ],
      }, {
        column: "2060",
        columnName: "2060年",
        width: "560px",
        children: [
          {
            column: "kf12060",
            columnName: "核电装机容量(亿千瓦)",
            width: "280px",
            children: [],
          }
        ],
      }

    ],
    data: [{
      dim1: '二代及三代大堆',
      dim3: '60年',
      dim4: '200亿',
      kf12030: '1.08',
      kf12040: '0.00',
      kf12050: '0.01',
      kf12060: '0.01'
    }, {
      dim1: '三代小堆',
      dim3: '60年',
      dim4: '400亿',
      kf12030: '2.46',
      kf12040: '0.02',
      kf12050: '0.01',
      kf12060: '0.01'
    }, {
      dim1: '四代堆（高温堆）',
      dim3: '40年',
      dim4: '100亿',
      kf12030: '3.23',
      kf12040: '0.18',
      kf12050: '0.74',
      kf12060: '0.01'
    }, {
      dim1: '四代堆（快堆）',
      dim3: '30年',
      dim4: '80亿',
      kf12030: '3.23',
      kf12040: '0.18',
      kf12050: '1.17',
      kf12060: '0.01'
    }]
  }
});

/** 节点单击事件 */
function handleNodeClick(data) {
  selectPeriodType.value = data;
  //渲染右侧的表单
  modelList.value = oldmodelList.value.filter(item => item.planAreaId == data.id);

  //点亮修改按钮
  single.value = false;
  multiple.value = false;
}


/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 查询参数模板列表 */
function getList() {
  loading.value = true;
  if (queryParams.value.code || queryParams.value.name || queryParams.value.type || queryParams.value.enable) {
    //按照条件过滤
    if (queryParams.value.code) {
      modelList.value = modelList.value.filter(item => item.code.indexOf(queryParams.value.code) != -1);
    }
    if (queryParams.value.name) {
      modelList.value = modelList.value.filter(item => item.name.indexOf(queryParams.value.name) != -1);
    }
    if (queryParams.value.type) {
      modelList.value = modelList.value.filter(item => item.type == queryParams.value.type);
    }
    if (queryParams.value.enable) {
      modelList.value = modelList.value.filter(item => item.enable == queryParams.value.enable);
    }
  } else {
    modelList.value = oldmodelList.value;
  }
  total.value = modelList.value.length;
  loading.value = false;
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

function iconHadler({row, rowIndex}) {
  row.index = rowIndex + 1;
}


/**
 * 查看模型
 */
function handleView(row) {
  openView.value = true;
  if (row.type === '1') {
    echartShow.value = true;
    charData.value = chartOptions.value;
  } else if (row.type === '0') {
    echartShow.value = true;
    charData.value = chartLineOptions2.value;
  } else if (row.type === '2') {
    echartShow.value = true;
    charData.value = pieOptions.value;
  } else if (row.type === '5') {
    echartShow.value = false;
  }
  nextTick(() => {
    const chart = myChart.value;
    if (chart) {
      chart.resize();
    }
  });
}

function cancelView() {
  openView.value = false;
}

function handleAdd() {
  open.value = true;
}

function getKeyfigureLabel(keyfigureIds) {
  // 使用 map 遍历 keyfigureIds 数组，对每个 id 查找对应的标签
  const labels = keyfigureIds.map(keyfigureId => {
    const option = keyfingureOptions.value.find(opt => opt.id === keyfigureId);
    return option ? option.name : '未知指标';
  });

  // 使用 join 方法将标签数组用逗号分隔并拼接成字符串
  return labels.join(',');
}

function getTypeLable(type) {
  if (type === '0') {
    return "折线图";
  } else if (type === '1') {
    return "柱状图";
  } else if (type === '2') {
    return "饼图";
  } else if (type === '3') {
    return "散点图";
  } else if (type === '4') {
    return "k线图";
  } else if (type === '5') {
    return "表格";
  } else {
    return "未知图形";
  }
}

function resetQuery() {
  modelList.value = oldmodelList.value;
}

function submitForm() {
  proxy.$refs["templateRef"].validate(valid => {
    if (valid) {
      if (form.value.id != null) {
        proxy.$modal.msgSuccess("修改成功");
        open.value = false;
        const model = modelList.value.find(item => item.id === form.value.id);
        const oldmodel = oldmodelList.value.find(item => item.id === form.value.id);

        //找到对应的数据进行修改
        model.id = form.value.id;
        model.planAreaId = form.value.planAreaId;
        model.code = form.value.code;
        model.name = form.value.name;
        model.enable = form.value.enable;
        model.keyfingureIds = form.value.keyfingureIds;
        model.type = form.value.type;

        //修改对应的保存数据的额值
        oldmodel.id = form.value.id;
        oldmodel.planAreaId = form.value.planAreaId;
        oldmodel.code = form.value.code;
        oldmodel.name = form.value.name;
        oldmodel.enable = form.value.enable;
        oldmodel.keyfingureIds = form.value.keyfingureIds;
        oldmodel.type = form.value.type;

        // getList();
      } else {
        open.value = false;
        //声明一个新的维度对象
        let model = {};
        model.id = modelList.value.length + 1;
        model.planAreaId = form.value.planAreaId;
        model.code = form.value.code;
        model.name = form.value.name;
        model.enable = form.value.enable;
        model.keyfingureIds = form.value.keyfingureIds;
        model.type = form.value.type;
        modelList.value.push(model);
        //oldmodelList.value.push(model);
        proxy.$modal.msgSuccess("新增成功");
      }
    }
  });

}

function getPlanAreaName(planAreaId) {
  const matchedNode = findNodeByPlanAreaId(categoryOptions.value, planAreaId);
  return matchedNode ? matchedNode.label : '未知的计划范围';
}

function findNodeByPlanAreaId(categories, planAreaId) {
  for (const category of categories) {
    if (category.id === planAreaId) {
      return category; // 找到匹配的节点，直接返回
    }
    if (category.children && category.children.length > 0) {
      const result = findNodeByPlanAreaId(category.children, planAreaId);
      if (result !== null) {
        return result; // 在子节点中找到匹配的节点，返回
      }
    }
  }
  return null; // 如果没有找到匹配的节点，则返回 null
}

function reset() {
  form.value = {
    id: null,
    code: null,
    name: null,
    planAreaId: null,
    enable: null,
    keyfingureIds: [],
    type: null,
    createTime: null,
    updateBy: null,
    updateTime: null
  };
  proxy.resetForm("templateRef");
}

function handleUpdate(row) {
  reset();
  open.value = true;
  title.value = "修改分析模型";
  form.value = row;
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

/** 删除按钮操作 */
function handleDelete(row) {
  if (row.id) {
    //const _ids = row.id;
    const name = row.name;
    proxy.$modal.confirm('是否确认删除分析模型："' + name + '"的数据项？').then(function () {
      //return delTemplate(_ids);
      //从数组总过滤掉
      modelList.value = modelList.value.filter(item => item.id !== row.id);
    }).then(() => {
      // getList();
      proxy.$modal.msgSuccess("删除成功");
    }).catch(() => {
    });
  } else {
    proxy.$modal.confirm('是否确认删除分析模型："' + ids.value + '"的数据项？').then(function () {
      //return delTemplate(_ids);
      //从数组总过滤掉
      modelList.value = modelList.value.filter(item => ids.value.includes(item.id));
    }).then(() => {
      // getList();
      proxy.$modal.msgSuccess("删除成功");
    }).catch(() => {
    });
  }
}

/** 通过条件过滤节点  */
const filterNode = (value, data) => {
  if (!value) return true;
  return data.label.indexOf(value) !== -1;
};

/** 根据名称筛选类别树 */
watch(categoryName, val => {
  proxy.$refs["categoryTreeRef"].filter(val);
});

getList();

</script>
<style>
.chart {
  width: 100%;
  height: 100%;
}
</style>